package com.supor.md_video.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.baseconfig.common.utils.Logc;
import com.pili.pldroid.player.IMediaController;
import com.supor.md_video.R;

public class VideoControllerView extends FrameLayout implements IMediaController {

    private String tag = "VideoController";
    private Context mContext;
    private ImageView ivVideo;

    public VideoControllerView(@NonNull Context context) {
        this(context, null);
    }

    public VideoControllerView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public VideoControllerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
        mContext = context;
        setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivVideo = new ImageView(mContext);
        ivVideo.setLayoutParams(new LayoutParams(150, 150));
        ivVideo.setBackgroundResource(R.mipmap.ic_video_play);
        addView(ivVideo);
    }

    @Override
    public void setMediaPlayer(MediaPlayerControl mediaPlayerControl) {
        Logc.i("lllll-" + tag + " setMediaPlayer");
    }

    @Override
    public void show() {
        Logc.i("lllll-" + tag + " show()");
        ivVideo.requestFocus();
        ivVideo.setVisibility(VISIBLE);
    }

    @Override
    public void show(int i) {
        Logc.i("lllll-" + tag + " show() " + i);
    }

    @Override
    public void hide() {
        Logc.i("lllll-" + tag + " hide()");
    }

    @Override
    public boolean isShowing() {
        return false;
    }

    @Override
    public void setAnchorView(View view) {
        Logc.i("lllll-" + tag + " setAnchorView");
    }
}
